package com.weixing.mall.provider.util;

import com.weixing.mall.base.enums.SnCodeEnum;
import com.weixing.mall.util.CommUtil;

/**
 * @Author wx
 * @Date 2020/1/10 11:45
 * @Version 1.0
 */
public class DepotUtil {

    //生成调拨单号
    public static  String genTransBillSn(long id){
        String transBillSn = parseTransBillSn(id);
        return SnCodeEnum.TRANSBILLSN.getValue().toString()+transBillSn;
    }

    private static String parseTransBillSn(long id){
        String transBillSn = String.valueOf(id);
        return transBillSn.length() < 8 ? CommUtil.uuid(8-transBillSn.length(),id):transBillSn;
    }

    //生成入库单号
    public static  String genInBillSn(long id){
        String InbillSn = parseInBillSn(id);
        return SnCodeEnum.INBILLSN.getValue().toString()+InbillSn;
    }
  /*  public static  String genInBillSn(){
        String InbillSn = parseInBillSn(id);
        return SnCodeEnum.INBILLSN.getValue().toString()+CommonUtil.uuid();
    }*/
    private static String parseInBillSn(long id){
        String InBillSn = String.valueOf(id);
        return InBillSn.length() < 8 ? CommUtil.uuid(8-InBillSn.length(),id):InBillSn;
    }

    //生成出库单号
    public static  String genOutBillSn(long id){
        String OutBillSn = parseOutBillSn(id);
        return SnCodeEnum.OUTBILLSN.getValue().toString()+OutBillSn;
    }

    private static String parseOutBillSn(long id){
        String OutBillSn = String.valueOf(id);
        return OutBillSn.length() < 8 ?  CommUtil.uuid(8-OutBillSn.length(),id):OutBillSn;
    }

    //生成盘点单号
    public static  String genCheckSn(long id){
        String CheckSn = parseCheckSn(id);
        return SnCodeEnum.CHECKSN.getValue().toString()+CheckSn;
    }
    /*
    *
    * */
    public static String genTransBillSn(String prefix,String fmtDate,Long seq) {
        String orderNo = prefix + fmtDate + parseTransNo(seq,3);
        return orderNo;
    }
    private static String parseTransNo(Long tNo, int len) {
        String transNo = String.valueOf(tNo);
        return transNo.length() < len ? String.format("%03d", tNo) : transNo;
    }
    private static String parseCheckSn(long id){
        String CheckSn = String.valueOf(id);
        return CheckSn.length() < 8 ? CommUtil.uuid(8-CheckSn.length(),id):CheckSn;
    }
}
